<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="format-detection" content="telephone=no" />
		<meta name="format-detection" content="email=no" />
		<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width;" />
		<title>修改密码</title>

		<link rel="stylesheet" type="text/css" href="../../css/person/changePassword.css" />
		<link rel="stylesheet" type="text/css" href="../../css/tool/comm.css" />

		<script type="text/javascript" src="../../plugins/zepto.js"></script>
  		<script type="text/javascript" src="../../js/tool/common.js"></script>

  		<link rel="stylesheet" type="text/css" href="../../plugins/layer/need/layer.css" />
  		<script type="text/javascript" src="../../plugins/layer/layer.js"></script>
	</head>
	<body style="background: #eee;">
		<div class="login-border">
			<div class="div-item">
				<div class="div-flag">手机号:</div>
				<div id="l_account" style="height: 42px;margin-top: 0px;" class="login-text"></div>
			</div>
			
			<div class="div-item">
				<div class="div-flag">旧的密码:</div>
				<input id="old_password" type="password" class="login-text" placeholder="请输入原密码" />
			</div>

			<div class="div-item">
				<div class="div-flag">新的密码:</div>
				<input id="l_newPassword" type="password" class="login-text" placeholder="请输入新密码（6-24位）" />
			</div>

			<div class="div-item">
				<div class="div-flag">确认密码:</div>
				<input id="l_surePassword" type="password" class="login-text" placeholder="请再次输入新密码" />
			</div>
		</div>

		<div class="comm-bottom-btn" style="clear: both; margin-top:60px;" onclick="changePassword()">
			<span class="comm-bottom-span " >确认</span>
		</div>
	</body>
	<script type="text/javascript">

		$(function(){
			$('#l_account').html(dataGet("userPhone"));
		})

		function changePassword() {
			var oldPassword = $('#old_password').val();
			var newPassword = $('#l_newPassword').val();
			var surePassword = $('#l_surePassword').val();

			if(oldPassword.length <6 || oldPassword.length > 20 ) {
				alert("原来密码（6-20个字符，数字或密码组成）");
				return;
			}

			if(newPassword.length <6 || newPassword.length > 20 ) {
				alert("密码（6-20个字符，数字或密码组成）");
				return;
			}

			if(newPassword!=surePassword) {
				alert("两次输入密码不一致");
				return;
			}

			if(surePassword.length <6 || surePassword.length > 20 ) {
				alert("请确认密码（6-20个字符，数字或密码组成）");
				return;
			}

			var userUuid = dataGet("userUuid");

			var data = "&crusrUuid="+userUuid+"&oldPwd="+oldPassword+"&newPwd="+newPassword+"&confirmPwd="+surePassword;
			var url = urlfile + "coreUser/update/pwd";
			ajaxTool("post",data,url,
				function error(XMLHttpRequest, textStatus, errorThrown,fnErr){
					alert("error:" + data);
				},
				function success(data){
					if(!data.success) {
						alert(data.errMsg);
					}else{
						history.back();
					}
				}
			);
		}
	</script>
</html>